package de.gist.calldurationwatcher.services;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;

public class ServiceManager {

	private static CallLoggingService callLoggingService;
	
	public static ServiceConnection mConnection = new ServiceConnection() {

		public void onServiceConnected(ComponentName className, IBinder binder) {
			callLoggingService = ((CallLoggingService.CallLogServiceBinder) binder).getService();
		}

		public void onServiceDisconnected(ComponentName className) {
			callLoggingService = null;
		}
	};
	
	public static CallLoggingService BindCallLogService(Context context) {
		context.bindService(new Intent(context, CallLoggingService.class), mConnection, Context.BIND_AUTO_CREATE);
		return callLoggingService;
	}
}
